<?php
/**
 * Created by PhpStorm.
 * User: 86188
 * Date: 2021/1/12
 * Time: 11:29
 */

namespace app\index\controller;


use think\Queue;

class Test
{
    public function testyangzl(){
        $redis = new \Redis();
        $redis->connect('127.0.0.1',6379);
        $redis->auth("zaozao2019@");
        $redis->select(1);
        $re=$redis->rpush("BillInvoiceFailed",218418);
        var_dump($re);
    }
    public function test(){
        $id=218418;
        $jobHandlerClassName  = 'app\admin\job\BillInvoice';
        $jobQueueName  	  = "BillInvoiceQueue";
        $jobData       	  = [ 'id' => $id ] ;
        $isPushed = Queue::push( $jobHandlerClassName , $jobData , $jobQueueName );
        var_dump($isPushed);

    }

    public function test4(){
        $redis = new \Redis();
        $redis->connect('127.0.0.1',6379);
        $redis->auth("zaozao2019@");
        $redis->select(1);

        $data = $redis->lrange('BillInvoiceFailed', 0, 999);
        foreach ($data as $value) {
            echo $value . "\n";
            $id=$value;
            $jobHandlerClassName  = 'app\admin\job\BillInvoice';
            $jobQueueName  	  = "BillInvoiceQueue";
            $jobData       	  = [ 'id' => $id ] ;
            $isPushed = Queue::push( $jobHandlerClassName , $jobData , $jobQueueName );
            var_dump($isPushed);

            $res=$redis->lrem('BillInvoiceFailed', $value, '-1');
            var_dump($res);
            echo "<br/>";
        }

}
    public function test2(){
        $redis = new \Redis();
        $redis->connect('127.0.0.1',6379);
        $redis->auth("zaozao2019@");
        $redis->select(1);
        $length = $redis->llen('BillInvoiceFailed');

        // 遍历list
        for ($i = 0; $i < $length; $i++) {
            // 获取list中的元素
            $value = $redis->lindex('BillInvoiceFailed', $i);
            $id=$value;
            $jobHandlerClassName  = 'app\admin\job\BillInvoice';
            $jobQueueName  	  = "BillInvoiceQueue";
            $jobData       	  = [ 'id' => $id ] ;
            $isPushed = Queue::push( $jobHandlerClassName , $jobData , $jobQueueName );
            var_dump($isPushed);

            $res=$redis->lrem('BillInvoiceFailed', $value, '-1');
            var_dump($res);
            echo "<br/>";
        }

        echo 'Yangzl';
    }

    public function test3(){
        $redis = new \Redis();
        $redis->connect('127.0.0.1',6379);
        $redis->auth("zaozao2019@");
        $redis->select(1);
        $res=$redis->lrem('BillInvoiceFailed', 218390, '-1');
        var_dump($res);
    }

}